import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Scanner;

/**
 * 计票统计
 * 请实现一个计票统计系统。你会收到很多投票，其中有合法的也有不合法的，请统计每个候选人得票的数量以及不合法的票数。
 */
public class HJ94 {
    public static void main(String[] args) {
        HashMap<String, Integer> map = new LinkedHashMap<>();
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()){
            int n = scanner.nextInt();
            for (int i = 0; i < n; i++) {
                map.put(scanner.next(),0);
            }
            int m = scanner.nextInt();
            String[] strings = new String[m];
            for (int i = 0; i < m; i++) {
                strings[i] = scanner.next();
            }
            int valid = 0;
            for (String s : strings) {
                if(map.containsKey(s)){
                    map.put(s,map.get(s)+1);
                }else {
                    valid++;
                }
            }

            for (String s : map.keySet()) {
                System.out.println(s+" : "+map.get(s));
            }
            System.out.println("Invalid : "+valid);

        }
    }
}
